package com.topwater.topwater.service.impl;

import com.topwater.topwater.entity.PyBalance;
import com.topwater.topwater.dao.PyBalanceDao;
import com.topwater.topwater.service.PyBalanceService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Param;

import javax.annotation.Resource;

/**
 * (PyBalance)表服务实现类
 *
 * @author 胡文 qq:986776
 * 自定义生成器制造
 */
@Service("pyBalanceService")
public class PyBalanceServiceImpl implements PyBalanceService {
    @Resource
    private PyBalanceDao pyBalanceDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public PyBalance queryById(Integer id) {
        return this.pyBalanceDao.queryById(id);
    }


    /**
     * 新增数据
     *
     * @param pyBalance 实例对象
     * @return 实例对象
     */
    @Override
    public PyBalance insert(PyBalance pyBalance) {
        this.pyBalanceDao.insert(pyBalance);
        return pyBalance;
    }

    @Override
    public PyBalance insertNotNull(PyBalance pyBalance) {
        this.pyBalanceDao.insertNotNull(pyBalance);
        return pyBalance;
    }

    /**
     * 修改数据
     *
     * @param pyBalance 实例对象
     * @return 实例对象
     */
    @Override
    public PyBalance update(PyBalance pyBalance) {
        this.pyBalanceDao.update(pyBalance);
        return this.queryById(pyBalance.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.pyBalanceDao.deleteById(id) > 0;
    }

    /**
     * 字符串自动模糊查询
     **/
    public List<PyBalance> queryByLike(PyBalance pyBalance) {
        return this.pyBalanceDao.queryByLike(pyBalance);
    }

    public List<PyBalance> queryByLike2(String str) {
        return this.pyBalanceDao.queryByLike2(str);
    }

    /**
     * 多表连接查询
     */
    public List<Map> queryJoin(@Param("pyBalance") PyBalance pyBalance, @Param("tables") String... tables) {
        return this.pyBalanceDao.queryJoin(pyBalance, tables);
    }
}
